////////////////////////////////////////////////////////////////////////////////
//
//  FLEX USER GROUP HOKURIKU
//  Copyright 2009 Flex User Group Hokuriku
//  All Rights Reserved.
// 
//  NOTICE: Flex User Group Hokuriku permits you to use, 
//  modify, and distribute this file 
//  in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////
package net.fxug.hokuriku.chocolat.model
{
    import org.flexunit.assertThat;
    import org.hamcrest.core.isA;
    import net.fxug.hokuriku.chocolat.model.A3TNDEventSearchCriteria;

    public class A3TNDEventSearchCriteriaTest
    {
        // Reference declaration for class to test
        private var target:net.fxug.hokuriku.chocolat.model.A3TNDEventSearchCriteria;

        public function A3TNDEventSearchCriteriaTest()
        {
        }

        [Test]
        public function testCreateQueryデフォルト():void
        {
            this.target = new A3TNDEventSearchCriteria;
            var result:String = this.target.createQuery();
            assertThat(result, isA("?start=1&count=10&format=json&"));
        }

        [Test]
        public function testCreateQueryEventId():void
        {
            this.target = new A3TNDEventSearchCriteria();
            this.target.eventIds = [1];
            var result:String = this.target.createQuery();
            assertThat(result, isA("?event_id=1&start=1&count=10&format=json&"));
        }

        [Test]
        public function testCreateQueryEventIds():void
        {
            this.target = new A3TNDEventSearchCriteria();
            this.target.eventIds = [1, 2];
            var result:String = this.target.createQuery();
            assertThat(result, isA("?event_id=1,2&start=1&count=10&format=json&"));
        }

        [Test]
        public function testCreateQueryCustomCount():void
        {
            this.target = new A3TNDEventSearchCriteria();
            this.target.count = 15;
            var result:String = this.target.createQuery();
            assertThat(result, isA("?start=1&count=15&format=json&"));
        }

        [Test]
        public function testCreateQueryKeyword():void
        {
            this.target = new A3TNDEventSearchCriteria();
            this.target.keywords = ["a"];
            var result:String = this.target.createQuery();
            assertThat(result, isA("?keyword=a&start=1&count=10&format=json&"));
        }

        [Test]
        public function testCreateQueryKeywords():void
        {
            this.target = new A3TNDEventSearchCriteria();
            this.target.keywords = ["a", "b"];
            var result:String = this.target.createQuery();
            assertThat(result, isA("?keyword=a,b&start=1&count=10&format=json&"));
        }

        [Test]
        public function testCreateQueryKeywordOR():void
        {
            this.target = new A3TNDEventSearchCriteria();
            this.target.keywordsOR = ["a"];
            var result:String = this.target.createQuery();
            assertThat(result, isA("?keyword_or=a&start=1&count=10&format=json&"));
        }

        [Test]
        public function testCreateQueryKeywordORs():void
        {
            this.target = new A3TNDEventSearchCriteria();
            this.target.keywordsOR = ["a", "b"];
            var result:String = this.target.createQuery();
            assertThat(result, isA("?keyword_or=a,b&start=1&count=10&format=json&"));
        }

        [Test]
        public function testCreateQueryYM():void
        {
            this.target = new A3TNDEventSearchCriteria();
            this.target.yms = [200911];
            var result:String = this.target.createQuery();
            assertThat(result, isA("?ym=200911&start=1&count=10&format=json&"));
        }

        [Test]
        public function testCreateQueryYMs():void
        {
            this.target = new A3TNDEventSearchCriteria();
            this.target.yms = [200911, 200811];
            var result:String = this.target.createQuery();
            assertThat(result, isA("?ym=200911,200811&start=1&count=10&format=json&"));
        }

        [Test]
        public function testCreateQueryYMD():void
        {
            this.target = new A3TNDEventSearchCriteria();
            this.target.ymds = [20091112];
            var result:String = this.target.createQuery();
            assertThat(result, isA("?ymd=20091112&start=1&count=10&format=json&"));
        }

        [Test]
        public function testCreateQueryYMDs():void
        {
            this.target = new A3TNDEventSearchCriteria();
            this.target.ymds = [20091112, 20081112];
            var result:String = this.target.createQuery();
            assertThat(result, isA("?ymd=20091112,20081112&start=1&count=10&format=json&"));
        }

        [Test]
        public function testCreateQueryNickName():void
        {
            this.target = new A3TNDEventSearchCriteria();
            this.target.nicknames = ["piyo"];
            var result:String = this.target.createQuery();
            assertThat(result, isA("?nickname=piyo&start=1&count=10&format=json&"));
        }

        [Test]
        public function testCreateQueryNickNames():void
        {
            this.target = new A3TNDEventSearchCriteria();
            this.target.nicknames = ["piyo", "hoge", 12];
            var result:String = this.target.createQuery();
            assertThat(result, isA("?nickname=piyo,hoge,12&start=1&count=10&format=json&"));
        }
    }
}